package com.liezh.factory.simple;

import com.liezh.factory.JsonRuleConfigParser;
import com.liezh.factory.IRuleConfigParser;
import com.liezh.factory.XmlRuleConfigParser;
import com.liezh.factory.YmlRuleConfigParser;

/**
 * @author liezh
 * @date 2022-5-6
 */
public class RuleConfigParserFactory {

    public IRuleConfigParser createParser(String configFormer) {
        configFormer = configFormer.toLowerCase();
        IRuleConfigParser parser = null;
        switch (configFormer) {
            case "json":
                parser = new JsonRuleConfigParser();
                break;
            case "xml":
                parser = new XmlRuleConfigParser();
                break;
            case "yml":
            case "yaml":
                parser = new YmlRuleConfigParser();
                break;
        }
        return parser;
    }

}
